﻿/// <reference path="../scripts/jquery-1.11.2.min.js" />
/// <reference path="../scripts/bootstrap.min.js" />

if (typeof ($) != "undefined" && $) {
    //验证用户
    CheckUser();
    $(document).ready(onReady);
}

function onReady() {
    $.ajax({
        type: "get",
        url: "api/member.ashx?ac=carList&k=" + Math.random(),
        beforeSend: function () {
            $('#loadingToast').show();
        },
        error: function () {
            showToast("数据加载失败");
        },
        success: function (data) {
            var list = eval("(" + data + ")");
            for (var i = 0; i < list.length; i++) {
                var o = list[i];
                var htm = '<div class="weui_cells weui_cells_access">';
                htm += '<div class="weui_cell" onclick="edit(' + o.Id + ')">';
                htm += '<div class="weui_cell_hd">';
                htm += '<img alt="logo" src="' + o.CarLogo + '" height="68px" width="68px" />';
                htm += '</div>';
                htm += '<div class="weui_cell_bd weui_cell_primary pl20">';
                htm += '车牌号：' + o.CarNumber + '<br />';
                htm += '车型：' + o.CarType + '<br />';
                htm += '颜色：' + o.Color + '<br />';
                htm += '</div>';
                htm += '<div class="weui_cell_ft" style="top:40px"></div>';
                htm += '</div>';
                htm += '</div>';

                $("#carList").append(htm);
            }
        },
        complete: function () {
            $('#loadingToast').hide();
        }
    });

    $("#divadd").click(function () {
        window.location.href = "car.html";
    });
}

function edit(id) {
    window.location.href = "car.html?cid=" + id;
}

